<template>
  <div>
   <MyHeader title="购物车案例" color="white" bgc="blue"></MyHeader>
   <div class="main">
     <MyGoods v-for="obj in list" :key="obj.id" :good="obj"></MyGoods>
   </div>
   <MyFooter :list="list"></MyFooter>
 </div>
</template>

<script>
import MyHeader from './components/MyHeader'
import MyGoods from './components/MyGoods'
import MyFooter from './components/MyFooter'
export default {
 components: {
   MyHeader,
   MyGoods,
   MyFooter
 },
 data(){
   return {
    list :[]
   }
 },
 //在created阶段获取数据，用list保存数据
 async created(){
     const {data:{list}} = await this.$axios({
      url: "/api/cart"
     })
     this.list=list
 }
}
</script>

<style>
 .main{
   padding-top: 45px;
   padding-bottom: 50px;
 }
</style>